package com.gk.panda.apis.dahua.dahuasdk.demo.frame.vto;


import com.gk.panda.apis.dahua.dahuasdk.lib.NetSDKLib.LLong;
import com.gk.panda.apis.dahua.dahuasdk.lib.NetSDKLib.fHaveReConnect;
import com.gk.panda.apis.dahua.service.SCADADemoHD;
import com.sun.jna.Pointer;


/**
 * 网络连接恢复，设备重连成功回调 通过 CLIENT_SetAutoReconnect 设置该回调函数，当已断线的设备重连成功时，SDK会调用该函数
 *
 * @author 47081
 */
public class DefaultHaveReconnect implements fHaveReConnect {
    private static DefaultHaveReconnect INSTANCE;

    private SCADADemoHD scadaDemoHD;

    public void setScadaDemoHD(SCADADemoHD scadaDemoHD) {
        this.scadaDemoHD = scadaDemoHD;
    }


    private DefaultHaveReconnect() {
        // TODO Auto-generated constructor stub
    }

    public static DefaultHaveReconnect getINSTANCE() {
        if (INSTANCE == null) {
            INSTANCE = new DefaultHaveReconnect();
        }
        return INSTANCE;
    }


    @Override
    public void invoke(LLong lLoginID, String pchDVRIP, int nDVRPort, Pointer dwUser) {
        System.out.printf("ReConnect lLoginID[%s] Device[%s] Port[%d]\n", lLoginID.toString(), pchDVRIP, nDVRPort);
        // 设备启动
        scadaDemoHD.reconnectRun(lLoginID);
    }
}
